<template>
  <el-container style="height: 100vh;">
    <!-- 左侧导航栏 -->
    <el-aside width="200px">
      <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b"
        router
      >
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>宿舍管理</span>
          </template>
          <el-menu-item index="/students">学生管理</el-menu-item>
          <el-menu-item index="/dormitories">宿舍信息</el-menu-item>
          <el-menu-item index="/allocation">宿舍分配</el-menu-item>
        </el-submenu>

        <el-menu-item index="/about">
          <i class="el-icon-info"></i>
          <span slot="title">关于系统</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <!-- 右侧内容区域 -->
    <el-container>
      <el-header>
        <h2>宿舍管理系统</h2>
      </el-header>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  methods: {
    handleOpen(key, keyPath) {
      console.log('菜单打开:', key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log('菜单关闭:', key, keyPath);
    }
  }
}
</script>

<style>
.el-aside {
  background-color: #545c64;
}

.el-header {
  background-color: #f5f7fa;
  padding: 15px;
  text-align: left;
  font-size: 20px;
  border-bottom: 1px solid #e4e7ed;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 100%;
  min-height: 400px;
}
</style>